home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / tsemac.zip / BOOK.S < prev    next >
Text File  |  1993-04-12  |  3KB  |  106 lines

  1. /************************************************************************
  2.   Author:  SemWare (Sammy Mitchell - original idea by by Jim Susoy and
  3.                         Howard Kapustein)
  4.   Date:    October   1992   Initial coding
  5.            April 10, 1993   Cleanup for public release
  6.  
  7.   Description:
  8.  
  9.   A couple of macros to give a visual display of active bookmarks.
  10.   Note that you should not mix using the regular bookmark commands with
  11.   these macros, as they will 'stomp' on each others bookmarks.
  12.  
  13.   Usage notes:
  14.  
  15.   To use, add these macros to your TSE.S file, and key assignments to
  16.   your TSE.KEY file, and re-bind the editor using the -b switch of sc.
  17.  
  18.   Example key assignments might be:
  19.  
  20.   <f11>         mPlaceBookMark()
  21.   <shift f11>   mGotoBookMark()
  22.  
  23.   !!!NOTE!!! If you do add this to your TSE.S file, remove the procedure
  24.   ListIt from this macro, as it duplicates the ListIt found in the default
  25.   TSE.S.
  26.  
  27.   Alternatively, add the key assignments to this file, and load the
  28.   macro (as an external macro) as needed via the LoadMacro command
  29.   (<ctrl f10><L> or 'menu->macro->load')
  30.  ************************************************************************/
  31.  
  32. integer proc ListIt(string title, integer width)
  33.     width = width + 4
  34.     if width > Query(ScreenCols)
  35.         width = Query(ScreenCols)
  36.     endif
  37.     return (List(title, width))
  38. end
  39.  
  40. // Place a bookmark - abandon the temporary 'visual' list of bookmarks first.
  41. proc loPlaceMark(integer i)
  42.     AbandonFile()
  43.     PopPosition()                       // restore position in file
  44.     PlaceMark(Chr(Asc('a') + i - 1))
  45.     Message("Bookmark placed")
  46. end
  47.  
  48. // Common routine to build the 'visual' list of bookmarks.
  49. proc mMarkSetup()
  50.     integer i, count, tid
  51.     string s[80]
  52.  
  53.     PushPosition()                      // save place
  54.     tid = CreateTempBuffer()            // for showing current marks
  55.     // Get the current marks
  56.     count = 1
  57.     i = 1
  58.     while i <= 26
  59.         if GotoMark(Chr(Asc('a') + i - 1))
  60.             // if mark there, add it to list of marks
  61.             s = Format(count:2, ': ',
  62.                 SplitPath(CurrFilename(), _NAME_ | _EXT_):-12, ' ',
  63.                 CurrLine():6, ' ', GetText(1, 50))
  64.             GotoBufferId(tid)
  65.             AddLine(s)
  66.             count = count + 1
  67.         endif
  68.         i = i + 1
  69.     endwhile
  70.     GotoBufferId(tid)
  71.     BegFile()
  72. end
  73.  
  74. proc mPlaceBookMark()
  75.     mMarkSetup()
  76.  
  77.     if NumLines() < 26
  78.         loPlaceMark(NumLines() + 1)
  79.     elseif ListIt("Place Bookmark", Query(ScreenCols))
  80.         loPlaceMark(CurrLine())
  81.     else
  82.         AbandonFile()
  83.         PopPosition()
  84.     endif
  85. end
  86.  
  87. proc mGotoBookMark()
  88.     integer i
  89.  
  90.     mMarkSetup()
  91.     i = 0
  92.     if NumLines() == 0
  93.         Warn("No Bookmarks found")
  94.     elseif ListIt("Goto Bookmark", Query(ScreenCols))
  95.         i = CurrLine()
  96.     endif
  97.     AbandonFile()                  // Delete the bookmark buffer
  98.     if i
  99.         KillPosition()
  100.         GotoMark(Chr(Asc('a') + i - 1))
  101.     else
  102.         PopPosition()
  103.     endif
  104. end
  105.  
  106.